/*
 * @Author: chenli chenli@kcwl.com
 * @Date: 2023-07-14 16:05:47
 * @LastEditors: chenli 604089679@qq.com
 * @LastEditTime: 2023-07-28 06:54:56
 * @FilePath: \jsnode\typescript\decorator\classDecorator.ts
 * @Description: 类装饰器
 */
//类装饰器
{
    const EatDec:ClassDecorator = (target: Function)=>{
        console.log('我是吃饭类装饰器');
        target.prototype.eat = ()=>{
            console.log('我们一起吃饭');
        }
    }
    const runDec:ClassDecorator = (target: Function)=>{
        console.log('我是跑步类装饰器');
        target.prototype.run = ()=>{
            console.log('我们一起跑步');
        }
    }

    @EatDec
    @runDec
    class Cat{
        [x: string]: any;
        constructor(){
            console.log('我是一只猫呀');
        }
        name: string='未知猫';
    }
    
    @EatDec
    @runDec
    class Dog {
        constructor(){
            console.log('我是一只狗呀');
        }
    }
    
    let cat = new Cat();
    cat.eat();
    (cat as any).run();
    console.log('我是分割线------------------------------------');
    let dog = new Dog();
    (dog as any).eat();
    (dog as any).run();
}

